# 格式化输出

name = "John"
greeting = f'Hello, I am {name}'
print(greeting)

radius = 5
pi = 3.14159
# : 用以格式化数据输出；'.2f' 是保留小数点2位； ',' 添加千分位符号
area = f" the area of this circle with radius {radius} is: {pi * radius ** 2 :.2f}"
print(area)

# : 用以格式化数据输出；',' 添加千分位符号
prices = 100000
print(f'the prices is ${prices}')
print(f'the prices is ${prices :,}')

# 换行输出
info = f"""
name: {name}
area: {area}
        """
print(info)

# 安全处理用户的输入 (用户可能输入恶意代码)
userInput = "<script>alert('xss')<script>"
safeMessage = f"User input： {userInput !r}"  # !r 用来转义变量中的特殊字符
print(safeMessage)